<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Apache module mod_dll</TITLE>
</HEAD>

<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<BODY
 BGCOLOR="#FFFFFF"
 TEXT="#000000"
 LINK="#0000FF"
 VLINK="#000080"
 ALINK="#FF0000"
>
<!--#include virtual="header.html" -->
<H1 ALIGN="CENTER">Module mod_dll</h1>

This module is contained in the <code>mod_dll.c</code> file, and is not
compiled in by default for Windows. It provides for loading of executable code
and modules into the server at start-up time, when they are contained in
Win32 DLLs.</p>

<h2>Summary</h2>

<p>The DLL module
loads other modules into the server as it is configuring itself (the
first time only, rereading the config files cannot affect the
state of loaded modules), when these modules are compiled into DLL files.</p>

<p>This module is included with Apache 1.3 and later, and is available
   only when using Microsoft Windows.</p>

<h2><a name="creating">Creating DLL Modules</a></h2>

<p>The Apache module API is unchanged between the Unix and Windows
   versions. Many modules will run on Windows with no or little change
   from Unix, although others rely on aspects of the Unix architecture
   which are not present in Windows, and will not work.</p>

<p>When a module does work, it can be added to the server in one of two
   ways. As with Unix, it can be compiled into the server. Because Apache
   for Windows does not have the <code>Configure</code> program of Apache
   for Unix, the module's source file must be added to the ApacheCore
   project file, and its symbols must be added to the
   <code>nt\modules.c</code> file.</p>

<p>The second way is to compile the module as a DLL, a shared library
   that can be loaded into the server at runtime, using the
   <code><a href="#loadmodule">LoadModule</a></code>
   directive. These module DLLs can be distributed and run on any Apache
   for Windows installation, without recompilation of the server.</p>

<p>To create a module DLL, a small change is necessary to the module's
   source file: The module record must be exported from the DLL (which
   will be created later; see below). To do this, add the
   <code>MODULE_VAR_EXPORT</code> (defined in the Apache header files) to
   your module's module record definition. For example, if your module
   has:</p>
<pre>
    module foo_module;
</pre>
<p>Replace the above with:</p>
<pre>
    module MODULE_VAR_EXPORT foo_module;
</pre>
<p>Note that this will only be activated on Windows, so the module can
   continue to be used, unchanged, with Unix if needed. Also, if you are
   familiar with <code>.DEF</code> files, you can export the module
   record with that method instead.</p>

<p>Now, create a DLL containing your module. You will need to link this
   against the ApacheCore.lib export library that is created when the
   ApacheCore.dll shared library is compiled. You may also have to change
   the compiler settings to ensure that the Apache header files are
   correctly located.</p>

<p>This should create a DLL version of your module. Now simply place it
   in the server root, and use the <code><a
   href="#loadmodule">LoadModule</a></code> directive to
   load it.</p>

<h2>Directives</h2>
<ul>
<li><A HREF="#loadfile">LoadFile</A>
<li><A HREF="#loadmodule">LoadModule</A>
</ul>
<hr>


<h2><A name="loadfile">LoadFile</A></h2>
<strong>Syntax:</strong> LoadFile <em>filename filename ...</em><br>
<Strong>Context:</strong> server config<br>
<strong>Status:</strong> Core (Windows)<br>
<strong>Module:</strong> mod_dll<p>

The LoadFile directive links in the named object files or libraries when
the server is started; this is used to load additional code which
may be required for some module to work. <em>Filename</em> is relative
to <A HREF="core.html#serverroot">ServerRoot</A>.<p><hr>

<h2><A name="loadmodule">LoadModule</A></h2>
<strong>Syntax:</strong> LoadModule <em>module filename</em><br>
<Strong>Context:</strong> server config<br>
<strong>Status:</strong> Core (Windows)<br>
<strong>Module:</strong> mod_dll<p>

The LoadModule directive links in the object file or library <em>filename</em>
and adds the module structure named <em>module</em> to the list of active
modules. <em>Module</em> is the name of the external variable of type
<code>module</code> in the file. Example:

<blockquote><code>
LoadModule status_module modules/ApacheModuleStatus.dll<br>
</code></blockquote>
loads the ApacheModuleStatus.dll module in the modules subdirectory of the
ServerRoot.<p>


<!--#include virtual="footer.html" -->
</BODY>
</HTML>

